﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InformationSystem.BLL.Core.Model
{
    public class Mail : BaseClass
    {
        public Mail()
        {
            this.RecvUserList = new List<RecvUser>();
            this.RecvGroupList = new List<RecvGroup>();
            this.RecvString = string.Empty;
        }
        public int MailID { get; set; }
        public string MailSubject { get; set; }
        public string SendUserID { get; set; }
        public string SendUserName { get; set; }
        public MailStatus MailStatus { get; set; }
        public bool HasAttachment { get; set; }
        public DateTime CreateTime { get; set; }
        public DateTime SendTime { get; set; }
        public string Content { get; set; }
        public List<RecvUser> RecvUserList { get; private set; }
        public IList<Attachment> AttachmentList { get; set; }
        public List<RecvGroup> RecvGroupList { get; private set; }
        public string RecvString { get; set; }

        public string RecvUserNameList
        {
            get
            {
                if (RecvString == string.Empty) return string.Empty;
                string[] tmprecv = RecvString.Split(',');
                string name = string.Empty;
                foreach (string item in tmprecv)
                {
                    int start = item.IndexOf('[');
                    int last = item.IndexOf(']');
                    if (start == -1 || last == -1) continue;
                    name += item.Substring(0, start) + ",";
                }
                name = name.TrimEnd(',');
                return name;
            }

        }
        /// <summary>
        /// 所属分组标签，形如 今天，一周内，更久
        /// </summary>
        public string GroupTip { get; set; }
    }
}
